package cn.tannn.ip2region.api;

import cn.tannn.ip2region.api.constants.IpConstants;
import cn.tannn.jdevelops.result.response.ResultVO;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * ip地址查询
 *
 * @author <a href="https://tannn.cn/">tan</a>
 * @date 2024/4/3 9:07
 */
@FeignClient(name = IpConstants.IP2REGION_SERVICES)
public interface IpApi {

    /**
     * 通过消息头获取ip并 获取 region - local
     * @param request ip
     * @return region
     */
    @Operation(summary = " 通过消息头获取ip并获取region")
    @GetMapping("region/at")
    ResultVO<String> findRegionAt(HttpServletRequest request);

    /**
     * 根据IP 获取 region - local
     * @param ip ip
     * @return region
     */
    @Operation(summary = "根据IP获取region[local]")
    @GetMapping("region")
    ResultVO<String> findRegion(@RequestParam("ip") String ip);

    /**
     * 根据IP 获取 region - whois.pconline.com.cn
     * @param ip ip
     * @return region
     */
    @Operation(summary = "根据IP获取region[whois.pconline.com.cn]")
    @GetMapping("region/pconline")
    ResultVO<String> findRegionFromPconline(@RequestParam("ip")String ip);



}
